﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Lottery.Client.SL.Util;

namespace Lottery.Client.SL.Controls
{
    public partial class NewsContent:UserControl
    {
        public Window Window { get; private set; }
        public event EventHandler ReadyToShow;
        public NewsContent()
        {
            InitializeComponent();
            SetControls();
        }
        public void SetHostWindow()
        {
            Screen.
                GetMonitorResolutionAsync
                ((w, h) =>
                     {
                         int t = h - 342-40;
                         int l = w - 420;
                         Window = Popup.GetWindow(this, l, t, 400, 300);
                         if (ReadyToShow != null)
                             ReadyToShow(this, EventArgs.Empty);
                     });
        }

        public void Show()
        {
            Window.Show();
        }

        private void SetControls()
        {
            this.MouseRightButtonDown += (o, e) =>
                                             {
                                                 e.Handled = true;
                                                 return;
                                             };
            btnClose.MouseLeftButtonDown += (o, e) => Window.Close();
            Minimized.MouseLeftButtonDown +=
                (o, e) => { Window.WindowState = WindowState.Minimized; };
            Rect.MouseLeftButtonDown += (o, e) => Window.DragMove();
        }
    }
}
